<div class="main-title">
    <h1 class="float-left">Users</h1>
    <span class="controls">
		<?php if (Yii::app()->user->checkAccess('ManageAgency.User.Manage')): ?>
			<a id="addUser" class="link-button with-icon" href="<?php echo $this->createUrl('users/adduser'); ?>">
				<img src="/images/icons/fugue/plus.png" />
				Add User
			</a>
		<?php endif; ?>
    </span>
</div>
<div class="grid_16">
	<div class="search-form">
		<?php
		$this->renderPartial('_search', array(
			'user' => $user
		));
		?>
	</div><!-- search-form -->
	<?php
	$form = $this->beginWidget('GxActiveForm', array(
		'id' => 'export-action-form',
		'method' => 'get'
	));
	?>
	<?php
	$this->widget('PsGridView', array(
		'id' => 'admin-users-grid',
		'dataProvider' => $dataProvider,
		'template' => '{pager}{summary}{items}{pagesize}{pager}',
		'summaryCssClass' => 'summary align-left',
		'pagerCssClass' => 'pager float-right',
		'pagesizeCssClass' => 'pager-pagesize float-left clearfix',
		'selectableRows' => 2,
		'htmlOptions' => array(
			'class' => 'grid-view no-shadow clearfix'
		),
		'itemsCssClass' => 'items fixed',
		'columns' => array(
//			'id' => array(
//				'class' => 'CCheckBoxColumn',
//				'value' => '$data->id',
//			),
			'photo' => array(
				'header' => '',
				'type' => 'raw',
				'value' => 'CHtml::image($data->getPhoto(), $data->name)',
				'headerHtmlOptions' => array('width' => 40),
				'htmlOptions' => array(
					'class' => 'agent-photo',
				)
			),
			'name' => array(
				'header' => 'Name',
				'name' => 'name',
				'type' => 'raw',
				'value' => 'CHtml::link(strtoupper($data->name), array("users/view", "id" => $data->id), array("class" => "bold blue link")) . ($data->getEffectiveDesignation() ? "<br/>" . $data->getEffectiveDesignation()->name : "") . "<div class=\"actions\">" . CHtml::link("Edit", array("users/update", "id" => $data->id)) . " | " . CHtml::link("View", array("users/view", "id" => $data->id)) . (Yii::app()->user->checkModuleAccess("Propsage.ImpersonateUser") ? (" | " . CHtml::link("Login", array("users/impersonate", "id" => $data->id))) : "") . "</div>"',
				'htmlOptions' => array(
					'class' => 'name',
				)
			),
			'username' => array(
				'header' => 'Username',
				'name' => 'username',
				'type' => 'raw',
				'value' => 'CHtml::link($data->username, array("users/view", "id" => $data->id), array("class" => ""))',
				'headerHtmlOptions' => array(
					'width' => 120,
				),
				'htmlOptions' => array(
					'class' => 'username no-wrap',
				)
			),
			'mobile' => array(
				'header' => 'Mobile',
				'value' => '$data->mobile',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission'),
				'headerHtmlOptions' => array(
					'width' => 100,
				),
			),
			'roles' => array(
				'header' => 'Roles',
				'value' => '$data->hasRoles() ? $data->getRoleNamesAsString() : "(None Assigned)"',
				'htmlOptions' => array(
//					'class' => 'no-wrap',
				)
			),
			'upline' => array(
				'header' => 'Upline',
				'value' => '$data->getUplineName()',
				'headerHtmlOptions' => array(
					'width' => 120,
				),
				'htmlOptions' => array(
					'class' => 'no-wrap',
				)
			),
			'cpd_hours' => array(
				'header' => 'CPD Hours',
				'class' => 'common.widgets.grid.PsPartialViewColumn',
				'view' => '_cpd_hours_column',
				'visible' => Yii::app()->user->checkModuleAccess("Propsage.CPD"),
				'headerHtmlOptions' => array(
					'width' => 100,
				),
			),
			'agency' => array(
				'header' => 'Agency',
				'name' => 'agencyName',
				'type' => 'raw',
				'value' => '$data->agency->name',
				'filter' => false,
				'headerHtmlOptions' => array('width' => 120),
				'htmlOptions' => array('class' => 'agency-column no-wrap'),
				'visible' => Yii::app()->user->hasMultipleAgenciesSelected()
			),
			'last_login' => array(
				'header' => 'Last Login',
				'type' => 'raw',
				'value' => '($data->last_login ? (DateFormatter::ago($data->last_login)) : "<span class=\"red\">Never</span>")',
				'headerHtmlOptions' => array(
					'width' => 100,
				),
			)
		)
	));
	?>
	<div id="bulk-actions-form" class=''>
		<?php echo GxHtml::submitButton(Yii::t('app', 'Export'), array('class' => 'blue', 'name' => 'action')); ?>
	</div>
	<br/>
	<?php $this->endWidget(); ?>
</div>